'''
Created on 12.11.2012

@author: felix_000
'''
from game.player.PlayerInterface import PlayerInterface
from game import GameLogic

class HumanPlayer(PlayerInterface):
    '''
    classdocs
    '''
    def setGUI(self, gui):
        self.gui = gui
        
    def event(self, action):
#        if action == GameLogic.SWAP_ACTION:
#            if self.switchAllowed:
#                self.action = action
        if GameLogic.isAllowed(self.field, action, self.color, set()):
            self.action = action
        else:
            print "Nope", action

    def requestAction(self, field, color, switchAllowed, ply):
        self.action = None
        self.field = field
        self.color = color
        self.switchAllowed = switchAllowed
        while self.action is None:
            self.gui.clock.tick(30)
        
        return self.action
    
    def stopable(self):
        return False
    
    def isHumanPlayer(self):
        return True

